<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const arr = [1, 2, 3]
    const [a, b, c] = arr
    const [d, e, f] = [1, 2, 3]
    console.log(a)//1
    console.log(b)//2
    console.log(c)//3
    console.log(d)//1
    console.log(e)//2
    console.log(f)//3
    console.log('-------------------------')
    //利用解构给两个数交换值
    let i = 1
    let j = 2;//分号不能省
    [j, i] = [i, j]
    console.log(i)//2
    console.log(j)//1
  </script>
</body>

</html>